import {
  createRouter,
  createWebHashHistory,
  RouteLocationNormalized,
  NavigationGuardNext,
} from 'vue-router'
import NProgress from 'nprogress'
import routes from './routes'

const VITE_BASE_URL = import.meta.env.VITE_BASE_URL

const router = createRouter({
  history: createWebHashHistory(VITE_BASE_URL as string),
  strict: true,
  routes,
})

router.beforeEach((to: RouteLocationNormalized, _, next: NavigationGuardNext) => {
  NProgress.start()

  next()
})

router.afterEach(() => {
  NProgress.done()
})

export default router
